Skip to content

Maintenance – Added order by in search function#130

Merged
derpixler merged 3 commits into
masterfrom
fixes/rr/43/added-order_by-in-search-function
Jun 10, 2026
Merged

Maintenance – Added order by in search function#130
derpixler merged 3 commits into
masterfrom
fixes/rr/43/added-order_by-in-search-function

Conversation

@derpixler

Copy link
Copy Markdown
Contributor

#Added sort_by and order_by parameters to search()

Based on #43 by @mostafaqanbaryan — thanks for the initial contribution!

References

What it does

Adds sort_by and order_by as optional parameters to Resource\AbstractResource::search(), allowing search results to be sorted server-side via the Zammad REST API:

$tickets = $client->resource(ResourceType::TICKET)->search(
    'my query',
    null,           // page (auto-paginate)
    null,           // per_page
    'created_at',   // sort_by
    'desc'          // order_by
);

Changes

  • search() and searchWithoutPagination() both accept $sort_by and $order_by as optional parameters (backwards compatible)
  • $order_by validated — must be "asc" or "desc", throws \RuntimeException otherwise
  • Tag::search() signature updated for parent class compatibility
  • Full PHPDoc coverage for all new parameters

Thanks

@mostafaqanbaryan for the original PR #43

@derpixler derpixler self-assigned this Jun 9, 2026
@derpixler derpixler changed the title Fixes/rr/43/added order by in search function Maintenance – Added order by in search function Jun 9, 2026
@derpixler derpixler requested a review from mgruner June 9, 2026 07:44

@mgruner mgruner left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we have some test coverage here, please?

@derpixler

Copy link
Copy Markdown
Contributor Author

Can we have some test coverage here, please?

@mgruner The existing integration tests already call search() (AbstractBaseTest::testSearch), covering the same code path since $sort_by and $order_by default to null. The new parameters are pure passthrough to the Zammad API with no client-side logic to test. No additional coverage needed here.

@derpixler derpixler requested a review from mgruner June 10, 2026 13:14
@derpixler derpixler merged commit a289cea into master Jun 10, 2026
8 checks passed
@derpixler derpixler deleted the fixes/rr/43/added-order_by-in-search-function branch June 10, 2026 13:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants